package com.zhcx.zhcxlibrary.utils;

import android.text.InputFilter;
import android.text.Spanned;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * ProjectName：WisdomBus
 * PackageName：com.zhcx.wisdombus.utils
 * description:表情处理工具
 * Date：2016/8/8 14:10
 * Author：Steven
 * ClassName:EmojiFilter
 **/
public class EmojiFilter implements InputFilter {

    Pattern emoji = Pattern.compile(
            "[\ud83c\udc00-\ud83c\udfff]|[\ud83d\udc00-\ud83d\udfff]|[\u2600-\u27ff]",
            Pattern.UNICODE_CASE | Pattern.CASE_INSENSITIVE);

    public EmojiFilter() {
        super();
    }

    @Override
    public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                               int dend) {
        Matcher emojiMatcher = emoji.matcher(source);
        if (emojiMatcher.find()) {
            return "";
        }
        return null;
    }

}
